import Vue from 'vue'
import VueCompositionAPI from '@vue/composition-api'

import 'normalize.css/normalize.css'// A modern alternative to CSS resets

import Element from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'

// 使用 Composition API（v-code-diff 依赖）
Vue.use(VueCompositionAPI)

import '@/styles/index.scss' // global css

import App from './App'
import router from './router'
import store from './store'

import i18n from './lang' // Internationalization
import './icons' // icon
import './errorLog'// error log
import './permission' // permission control
import VueClipboard from 'vue-clipboard2'

import * as filters from './filters' // global filters

// 导入 Markdown 编辑器
import VueMarkdownEditor from '@kangc/v-md-editor'
import '@kangc/v-md-editor/lib/style/base-editor.css'
import vuepressTheme from '@kangc/v-md-editor/lib/theme/vuepress.js'
import '@kangc/v-md-editor/lib/theme/style/vuepress.css'

// 配置 Markdown 编辑器
VueMarkdownEditor.use(vuepressTheme)
// 设置全局默认配置
VueMarkdownEditor.defaultConfig = {
  defaultShowPreview: false // 默认关闭预览功能
}
Vue.use(VueMarkdownEditor)

Vue.use(Element, {
  size: 'medium', // set element-ui default size
  i18n: (key, value) => i18n.t(key, value)
})

// register global utility filters.
Object.keys(filters).forEach(key => {
  Vue.filter(key, filters[key])
})

Vue.use(VueClipboard)
Vue.config.productionTip = false
// 初始化项目配置
store.dispatch('getProjectsFromCookies')
new Vue({
  el: '#app',
  router,
  store,
  i18n,
  render: h => h(App)
})
